package com.atguigu.day04.test;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/2 17:05
 * @注释 九九乘法表, 平行四边形, 打印菱形
 */

//九九乘法表
public class ForForTest1 {
    public static void main(String[] args) {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + i * j + "\t");
            }
            System.out.println();
        }
    }
}

//打印平行四边型
class ForForTest2 {
    public static void main(String[] args) {
        for (int i = 1; i <= 4; i++) {
            switch (i) {
                case 1:
                    System.out.print(" ");
                case 2:
                    System.out.print(" ");
                case 3:
                    System.out.print(" ");
            }
            for (int j = 1; j <= 8; j++) {

                System.out.print("*");
            }
            System.out.println();
        }
    }
}

//打印菱形
class ForForTest3 {
    public static void main(String[] args) {
        //嵌套循环 打印菱形
        for (int i = 1; i <= 5; i++) {
            //打印空格
            for (int j = 1; j <= 5 - i; j++) {
                System.out.print(" ");
            }
            //打印星星
            for (int k = 1; k <= i; k++) {
                System.out.print("* ");
            }
            //打印换行
            System.out.println();
        }
        //打印下半部分
        for (int i = 1; i <= 4; i++) {
            //打印空格
            for (int j = 1; j <= i; j++) {
                System.out.print(" ");
            }
            //打印星号
            /*for (int k = 1; k <= 5 - i; k++) {
                System.out.print("* ");
            }*/
            for (int k = 4; k >= i; k--) {
                System.out.print("* ");
            }
            //打印换行
            System.out.println();
        }

        //单层循环 打印菱形
        /*for (int i = 1; i <= 9; i++) {
            switch (i) {
                case 1,9:
                    System.out.print(" ");
                case 2,8:
                    System.out.print(" ");
                case 3,7:
                    System.out.print(" ");
                case 4,6:
                    System.out.print(" ");
            }
            if (i <= 5) {
                for (int j = 1; j <= i; j++) {
                    System.out.print("* ");
                }
            }else{
                for (int j = 1; j <= 10 - i; j++) {
                    System.out.print("* ");
                }
            }
            System.out.println();

        }*/
    }
}